package day5.problem1;

import java.util.*;

//游游的you
//https://www.nowcoder.com/questionTerminal/cd117803b3364b218a8b3dcc498dee25

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while(t-- > 0) {
            // y o u
            long a = in.nextInt();
            long b = in.nextInt();
            long c = in.nextInt();
            long sum = 0;
            long m = Math.min(a,Math.min(b, c));
            sum += m * 2;
            a -= m;b-=m;c-=m;
            if(b >= 2) sum += b-1;
            System.out.println(sum);
        }
    }
}
